//
//  TXP_RadioTableViewCell.m
//  StayAwhile
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXP_RadioTableViewCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
#import <MJRefresh.h>
@interface TXP_RadioTableViewCell ()
@property (nonatomic, retain) UIImageView *coverImg;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *unameLabel;
@property (nonatomic, retain) UILabel *descLabel;
@property (nonatomic, retain) UILabel *countLabel;
@property (nonatomic, retain) UIImageView *tagImg;

@end
@implementation TXP_RadioTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self createSubView];
    }
    return self;
}
- (void)createSubView{
    self.coverImg = [[UIImageView alloc] init];
    self.coverImg.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.coverImg];
    
   [self.coverImg mas_makeConstraints:^(MASConstraintMaker *make) {
       
       make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(5, 5, 5, WIDTH-110));
   }];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.backgroundColor = [UIColor clearColor];
    self.titleLabel.text = @"独家记忆";
    [self.contentView addSubview:self.titleLabel];
    
   [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
       make.left.mas_equalTo(self.coverImg.mas_right).offset(10);
       make.right.mas_equalTo(self.mas_right).offset(-40);
       make.top.mas_equalTo(self.mas_top).offset(12);
       make.bottom.mas_equalTo(self.mas_top).offset(40);
   }];
    
       self.descLabel = [[UILabel alloc] init];
    self.descLabel.backgroundColor = [UIColor clearColor];
    self.descLabel.text = @"喜欢讲故事的习俗也";
    self.descLabel.textColor = RGBA(136, 159, 163, 1);
    self.descLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview: self.descLabel];
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.coverImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-40);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(15);
        make.bottom.mas_equalTo(self.titleLabel.mas_bottom).offset(30);
    }];
    
    self.unameLabel = [[UILabel alloc] init];
    
    self.unameLabel.backgroundColor = [UIColor clearColor];
    self.unameLabel.textColor = RGBA(191, 191, 192, 1);
    self.unameLabel.font = [UIFont systemFontOfSize:11];
    self.unameLabel.text = @"222";
    [self.contentView addSubview:self.unameLabel];
    [self.unameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.coverImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-40);
        make.top.mas_equalTo(self.descLabel.mas_bottom).offset(10);
        make.bottom.mas_equalTo(self.descLabel.mas_bottom).offset(20);
    }];

    self.tagImg = [[UIImageView alloc] init];
    self.tagImg.image = [UIImage imageNamed:@"listen"];
    [self.contentView addSubview:self.tagImg];
    [self.tagImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.coverImg.mas_right).offset(200);
        make.right.mas_equalTo(self.mas_right).offset(-80);
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-80);
        
    }];
        
    self.countLabel = [[UILabel alloc] init];
    self.countLabel.font = [UIFont systemFontOfSize:10];
    self.countLabel.text = @"12345678";
    self.countLabel.textColor = [UIColor colorWithRed:170 / 255.0 green:170 / 255.0 blue:170 / 255.0 alpha:1.0];
    [self.contentView addSubview:self.countLabel];
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.tagImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-80);
        
    }];
   
}
- (void)setModel:(TXPRadioModel *)model{
    
    _model = model;
    
    NSURL *url = [NSURL URLWithString:_model.coverimg];
    [self.coverImg sd_setImageWithURL:url placeholderImage:nil];
    self.titleLabel.text = _model.title;
    self.descLabel.text = [NSString stringWithFormat:@"by:%@",_model.infoModel.uname];
    self.unameLabel.text = _model.desc;
    self.countLabel.text = [NSString stringWithFormat:@"%@",_model.count];
}
@end
